<?php

namespace App\Http\Controllers;

use Illuminate\Foundation\Bus\DispatchesJobs;
use Illuminate\Routing\Controller as BaseController;
use Illuminate\Foundation\Validation\ValidatesRequests;
use Illuminate\Foundation\Auth\Access\AuthorizesRequests;

class Controller extends BaseController
{
    use AuthorizesRequests, DispatchesJobs, ValidatesRequests;
    protected function safe_check($info) {
        if(is_array($info)) {
            foreach ($info as $key=> $value) {
                $info[$key] = $this->safe_check($value);
            }
        } elseif(is_string($info)) {
            $info = htmlspecialchars($info);
        }
        return $info;
    }
    //返回json
    protected function message($condition, $message, $data=null) {
        $result = array();
        $result['condition'] = intval($condition);
        $result['message']   = $message;
        if(!is_null($data) && is_array($data)) {
            foreach ($data as $key => $val)
                $result[$key] = $data[$key];
        }
        return json_encode($result);
    }
}
